package com.qst.action.exam;


import com.qst.BaseServlet;
import com.qst.RequestUtil;
import com.qst.WebUtil;
import com.qst.entity.Exam;
import com.qst.service.ExamService;
import com.qst.service.impl.ServiceFactory;

import javax.servlet.ServletException;
import javax.servlet.annotation.WebServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import java.io.IOException;


//@WebServlet("/exam/result.action")
public class ResultServlet extends BaseServlet {
    private ExamService examService = ServiceFactory.getService(ExamService.class);
    @Override
    protected void doAction(HttpServletRequest req, HttpServletResponse resp) throws ServletException, IOException {
        super.doAction(req, resp);
        int resultId = RequestUtil.getInt(req, "id");
        Exam exam = examService.getExamResult(resultId);
        StringBuffer stf=new StringBuffer();
        stf.append("../analysis/");
        stf.append(exam.getResult());
        stf.append(".jsp");
        req.setAttribute("examresult", stf.toString());
        req.setAttribute("exam",exam);

        WebUtil.forward(req, resp, "/exam/result.jsp");
    }
}
